//Use with LUA_DRIL, LUS_NEOD, and Lua_RDAR
//Neo Drilla
freeslot(
	"MT_NEODRILLA",
	"S_NEDR_STAND",
	"S_NEDR_STAND2",
	"S_NEDR_RUN",
	"S_NEDR_RUN2",
	"S_NEDR_RUN3",
	"S_NEDR_RUN4",
	"S_NEDR_RUN5",
	"S_NEDR_RUN6",
	"S_NEDR_JAB",
	"S_NEDR_JAB2",
	"S_NEDR_JAB3",
	"S_NEDR_JAB4",
	"S_NEDR_JAB5",
	"S_NEDR_JAB6",
	"S_NEDR_JAB7",
	"S_NEDR_JAB8",
	"S_NEDR_JAB9",
	"S_NEDR_JAB10",
	"S_NEDR_JAB11",
	"S_NEDR_JAB12",
	"SPR_NEDR"
)

//Touch Special Lua made by toaster 
addHook("TouchSpecial", function(mo, pmo)
    local ang = (R_PointToAngle2(mo.x, mo.y, pmo.x, pmo.y) - mo.angle)/ANG1
    if (((ANGLE_337h/ANG1) < ang) and (ang < 23) // this line was fixed by inferno vountarly.
    and not (pmo.player.powers[pw_invulnerability])
    and not (pmo.player.powers[pw_super]))
        P_DamageMobj(pmo, mo, mo)
        return true
    end
end, MT_NEODRILLA)
 
addHook("MobjThinker", function(mo)
    if (S_SoundPlaying(mo, sfx_drill1) or S_SoundPlaying(mo, sfx_drill2)) return end
 
    if not mo.target
        if mo.start
            mo.start = 0
        end
        return
    end
 
    if mo.start
        S_StartSound(mo, sfx_drill2)
    else
        S_StartSound(mo, sfx_drill1)
        mo.start = 1
    end
end, MT_NEODRILLA)


mobjinfo[MT_NEODRILLA] = {
//$Name "Neo Drilla"
//$Sprite NEDRA1
//$Category Custom Enemies
	doomednum = 2025,
	spawnstate = S_NEDR_STAND,
	spawnhealth = 1,
	seestate = S_NEDR_RUN,
	reactiontime = 3,
	attacksound = sfx_s3kab,
	painchance = 5,
	meleestate = S_NEDR_JAB,
	deathstate = S_XPLD_FLICKY,
	deathsound = sfx_pop,
	xdeathstate = 160,
	speed = 3,
	radius = 24*FRACUNIT,
	height = 32*FRACUNIT,
	mass = 100,
	flags = MF_SPECIAL|MF_SHOOTABLE|MF_ENEMY
}

states[S_NEDR_STAND] =	{SPR_NEDR,	A,	1,	A_RadarLook,	0,	0,	S_NEDR_STAND2}
states[S_NEDR_STAND2] =	{SPR_NEDR,	A,	1,	A_RadarLook,	0,	0,	S_NEDR_STAND}
states[S_NEDR_RUN] =	{SPR_NEDR,	A,	1,	A_NeoChase,	0,	192,	S_NEDR_RUN2}
states[S_NEDR_RUN2] =	{SPR_NEDR,	B,	2,	A_NeoChase,	0,	192,	S_NEDR_RUN3}
states[S_NEDR_RUN3] =	{SPR_NEDR,	C,	2,	A_NeoChase,	0,	192,	S_NEDR_RUN4}
states[S_NEDR_RUN4] =	{SPR_NEDR,	D,	2,	A_NeoChase,	0,	192,	S_NEDR_RUN5}
states[S_NEDR_RUN5] =	{SPR_NEDR,	E,	2,	A_NeoChase,	0,	192,	S_NEDR_RUN6}
states[S_NEDR_RUN6] =	{SPR_NEDR,	F,	2,	A_NeoChase,	0,	192,	S_NEDR_RUN}
states[S_NEDR_JAB] =	{SPR_NEDR,	A,	5,	A_PlayAttackSound,	0,	0,	S_NEDR_JAB2}
states[S_NEDR_JAB2] =	{SPR_NEDR,	B,	1,	A_Repeat,	3,	S_NEDR_JAB,	S_NEDR_JAB3}
states[S_NEDR_JAB3] =	{SPR_NEDR,	C,	1,	A_FaceTarget,	0,	0,	S_NEDR_JAB4}
states[S_NEDR_JAB4] =	{SPR_NEDR,	D,	1,	A_Thrust,	5,	0,	S_NEDR_JAB5}
states[S_NEDR_JAB5] =	{SPR_NEDR,	E,	1,	A_Thrust,	5,	0,	S_NEDR_JAB6}
states[S_NEDR_JAB6] =	{SPR_NEDR,	F,	1,	A_Thrust,	5,	0,	S_NEDR_JAB7}
states[S_NEDR_JAB7] =	{SPR_NEDR,	A,	1,	A_Thrust,	5,	0,	S_NEDR_JAB8}
states[S_NEDR_JAB8] =	{SPR_NEDR,	B,	1,	A_Thrust,	5,	0,	S_NEDR_JAB9}
states[S_NEDR_JAB9] =	{SPR_NEDR,	C,	1,	A_Thrust,	5,	0,	S_NEDR_JAB10}
states[S_NEDR_JAB10] =	{SPR_NEDR,	D,	1,	A_Thrust,	5,	0,	S_NEDR_JAB11}
states[S_NEDR_JAB11] =	{SPR_NEDR,	E,	1,	A_Thrust,	5,	0,	S_NEDR_JAB12}
states[S_NEDR_JAB12] =	{SPR_NEDR,	F,	15,	A_Thrust,	5,	0,	S_NEDR_RUN}

//Puyo
if not(kirbyabilitytable)
    rawset(_G, "kirbyabilitytable", {})
end
kirbyabilitytable[MT_NEODRILLA] = 6    // Makes MT_NEODRILLA give Needle
